﻿package frEngine.loaders.particleSub
{
    import flash.geom.*;
    import flash.system.*;
    import frEngine.animateControler.particleControler.*;
    import frEngine.effectEditTool.parser.def.*;
    import frEngine.loaders.*;
    import frEngine.loaders.particleSub.multyEmmiterType.*;
    import frEngine.loaders.particleSub.particleInstance.*;
    import frEngine.math.*;

    public class ParticleParser extends Object
    {
        private var _particleParams:ParticleParams;
        private var _errorInfo:String;
        private var _instancingObject:OneParticleInstance;
        private var _directionInfo:Object;
        private var _autoRotationInfo:Object;
        private var _faceTransform:Matrix3D;
        private var _useThread:Boolean;

        public function ParticleParser(param1:Boolean)
        {
            this._useThread = param1;
            return;
        }// end function

        public function set errorInfo(param1:String) : void
        {
            this._errorInfo = param1;
            return;
        }// end function

        public function parser(param1:ParticleParams, param2:Object) : String
        {
            this._particleParams = param1;
            this._particleParams.clear();
            this._particleParams.blendType = EngineConstName.getBlendModeByName(param2.blendMode);
            this._particleParams.playMode = EngineConstName.getPlayModeByName(param2.playMode);
            this._errorInfo = null;
            this.parserHeadInfo(param2);
            this.parserBaseInfo(param2);
            this.parserEmitterInfo(param2);
            this.parserAnimInfo(param2);
            if (this._errorInfo == null)
            {
                this._particleParams.initObjects(this._instancingObject, this._autoRotationInfo, this._directionInfo, this._faceTransform);
            }
            return this._errorInfo;
        }// end function

        private function getMultyEmmiterClass(param1:String) : Class
        {
            var _loc_2:Class = null;
            switch(param1)
            {
                case ELineType.point:
                {
                    _loc_2 = PointMultyEmmiter;
                    break;
                }
                case ELineType.linear:
                {
                    _loc_2 = LinearMultyEmmiter;
                    break;
                }
                case ELineType.curveLine:
                {
                    _loc_2 = CurveLineMultyEmmiter;
                    break;
                }
                default:
                {
                    break;
                }
            }
            return _loc_2;
        }// end function

        public function clear() : void
        {
            this._particleParams = null;
            return;
        }// end function

        private function parserAnimInfo(param1:Object) : void
        {
            if (this._errorInfo)
            {
                return;
            }
            this.createFingerUvAnim(param1);
            this.createUvAnim(param1);
            this.createSizeAnim(param1);
            this.createForceAnim(param1);
            this.createShvAnim(param1);
            this.createFrictionAnim(param1);
            this.createColorAnim(param1);
            this.createRotateAnim(param1);
            this.createDistanceBirth(param1);
            this.createGrowthAndFadeAnim(param1);
            this._particleParams.tailEnabled = param1.tailEnabled;
            this._particleParams.inertiaValue = this._particleParams.tailEnabled && param1.inertia ? (param1.inertiaValue) : (0);
            this._particleParams.tailMaxDistance = param1.tailMaxDistance;
            this.createCenterOffset(param1);
            if (param1.useIndividualPos)
            {
                this._particleParams.tailEnabled = true;
                this._particleParams.tailMaxDistance = 1000000;
            }
            if (param1.rotateAxisY)
            {
                this._particleParams.rotateAxisYSpeed = param1.rotateAxisYSpeed / 10;
                this._particleParams.rotateAxisFlag = param1.axis;
            }
            else
            {
                this._particleParams.rotateAxisYSpeed = 0;
            }
            return;
        }// end function

        private function createCenterOffset(param1:Object) : void
        {
            var _loc_5:Array = null;
            var _loc_2:Number = 0;
            var _loc_3:Number = 0;
            var _loc_4:Number = 0;
            if (param1.centerOffset)
            {
                _loc_5 = param1.centerOffset.split(",");
                _loc_5[0] = String(_loc_5[0]);
                _loc_5[1] = String(_loc_5[1]);
                _loc_5[2] = String(_loc_5[2]);
                _loc_2 = Number(_loc_5[0]);
                _loc_3 = Number(_loc_5[1]);
                _loc_4 = Number(_loc_5[2]);
                if (isNaN(_loc_2))
                {
                    _loc_2 = 0;
                }
                if (isNaN(_loc_3))
                {
                    _loc_3 = 0;
                }
                if (isNaN(_loc_4))
                {
                    _loc_4 = 0;
                }
            }
            this._particleParams.centerOffset.x = _loc_2;
            this._particleParams.centerOffset.y = _loc_3;
            this._particleParams.centerOffset.z = _loc_4;
            return;
        }// end function

        private function createFingerUvAnim(param1:Object) : void
        {
            if (param1.uvUserAnim)
            {
                this._particleParams.uvFingerConst = new XYZObject();
                this._particleParams.uvFingerConst.init(param1.uNum2, param1.vNum2, 0, 0);
                if (param1.fingerFrame == "")
                {
                    this._particleParams.uvFingerFrames = [];
                }
                else
                {
                    this._particleParams.uvFingerFrames = String(param1.fingerFrame).split(",");
                }
            }
            else
            {
                this._particleParams.uvFingerConst = null;
                this._particleParams.uvFingerFrames = null;
            }
            return;
        }// end function

        private function createDistanceBirth(param1:Object) : void
        {
            this._particleParams.distanceBirth = param1.distanceBirth;
            this._particleParams.birthDistance = param1.birthDistance;
            return;
        }// end function

        private function createFrictionAnim(param1:Object) : void
        {
            var _loc_2:XYZObject = null;
            if (param1.frictionEnabled)
            {
                _loc_2 = new XYZObject();
                _loc_2.init(param1.rictionSizeX, param1.rictionSizeY, param1.rictionSizeZ);
                this._particleParams.frictionVecor3d = _loc_2;
            }
            else
            {
                this._particleParams.frictionVecor3d = null;
            }
            return;
        }// end function

        private function createGrowthAndFadeAnim(param1:Object) : void
        {
            if (param1.sizeTimeEnabled)
            {
                this._particleParams.useGrowthAndFade = true;
                this._particleParams.isFadeToGrowth = param1.fadeType == EngineConstName.FADETOGROWTH;
                this._particleParams.growth_time = param1.addSizeTime;
                this._particleParams.fade_time = param1.subSizeTime;
                this._particleParams.gf_smooth = param1.useGFSmooth;
                var _loc_2:Number = -0.001;
                this._particleParams.fade_time = -0.001;
                var _loc_2:Number = -0.001;
                this._particleParams.growth_time = -0.001;
            }
            else
            {
                this._particleParams.useGrowthAndFade = false;
            }
            return;
        }// end function

        private function createUvAnim(param1:Object) : void
        {
            var _loc_2:XYZObject = null;
            var _loc_3:Array = null;
            var _loc_4:Array = null;
            var _loc_5:Object = null;
            if (param1.uvStepAnim)
            {
                _loc_2 = new XYZObject();
                _loc_2.init(param1.uNum, param1.vNum, param1.uvSpeed, param1.uvOffset);
                this._particleParams.uvStep = _loc_2;
            }
            else
            {
                this._particleParams.uvStep = null;
            }
            if (param1.uvOffsetAnim)
            {
                _loc_3 = String(param1.uvStart).split(" ");
                _loc_4 = String(param1.uvEnd).split(" ");
                _loc_2 = new XYZObject();
                _loc_2.init(_loc_3[0], _loc_3[1], _loc_4[0] - _loc_3[0], _loc_4[1] - _loc_3[1]);
                this._particleParams.uvOffset = _loc_2;
                _loc_5 = param1.uvOffsetSmooth;
                if (_loc_5 && _loc_5.selected)
                {
                    this._particleParams.setUvOffsetSmooth(_loc_5.keyFrames);
                }
                else
                {
                    this._particleParams.setUvOffsetSmooth(null);
                }
            }
            else
            {
                this._particleParams.uvOffset = null;
                this._particleParams.setUvOffsetSmooth(null);
            }
            return;
        }// end function

        private function createSizeAnim(param1:Object) : void
        {
            var _loc_2:* = param1.particalSizeSmooth;
            if (_loc_2 && _loc_2.keyFrames && _loc_2.selected)
            {
                this._particleParams.useParticleSize = true;
                this._particleParams.setSizeSmooth(_loc_2.keyFrames);
            }
            else
            {
                this._particleParams.setSizeSmooth(null);
            }
            return;
        }// end function

        private function createForceAnim(param1:Object) : void
        {
            var _loc_2:XYZObject = null;
            if (param1.useForce)
            {
                _loc_2 = new XYZObject();
                _loc_2.init(param1.forceX, param1.forceY, param1.forceZ, param1.forceSize / 100);
                _loc_2.normalize();
                this._particleParams.lineForceVecor3d = _loc_2;
            }
            else
            {
                this._particleParams.lineForceVecor3d = null;
            }
            this._particleParams.lixinForceSize = param1.useLixinForce ? (param1.lixinForceSize / 100) : (0);
            return;
        }// end function

        private function createShvAnim(param1:Object) : void
        {
            var _loc_2:XYZObject = null;
            var _loc_3:XYZObject = null;
            if (param1.useSimpleHarmonicVibration)
            {
                this._particleParams.useSimpleHarmonicVibration = true;
                _loc_2 = new XYZObject();
                _loc_2.init(param1.shvX, param1.shvY, param1.shvZ);
                _loc_2.normalize();
                this._particleParams.shvDirection = _loc_2;
                _loc_3 = new XYZObject();
                _loc_3.init(param1.shvCycle / (2 * Math.PI), param1.shvAmplitude, param1.shvOffset, param1.shvOffset_variation);
                this._particleParams.shvValue = _loc_3;
            }
            else
            {
                this._particleParams.useSimpleHarmonicVibration = false;
            }
            return;
        }// end function

        private function createRotateAnim(param1:Object) : void
        {
            this._autoRotationInfo = null;
            if (param1.isUseAutoRoation)
            {
                if (param1.roationType == "速度方向")
                {
                    this._particleParams.useRotateToVelocity = true;
                }
                else
                {
                    this._particleParams.useRotateToVelocity = false;
                    this._autoRotationInfo = new Object();
                    this._autoRotationInfo.type = param1.roationType == EngineConstName.axixType2 ? (1) : (0);
                    this._autoRotationInfo.axis = new Vector3D(param1.roationX, param1.roationY, param1.roationZ);
                    this._autoRotationInfo.axisVar = param1.roationVar;
                    this._autoRotationInfo.angle = param1.roationAngle;
                    this._autoRotationInfo.angleVar = param1.roationAngleVar;
                    this._autoRotationInfo.offsetAngle = param1.offsetAngle;
                    this._autoRotationInfo.offsetAngleVar = param1.offsetAngleVar;
                }
            }
            else
            {
                this._particleParams.useRotateToVelocity = false;
            }
            return;
        }// end function

        private function createColorAnim(param1:Object) : void
        {
            var _loc_8:Array = null;
            var _loc_9:int = 0;
            var _loc_10:Array = null;
            var _loc_11:Array = null;
            var _loc_12:Array = null;
            var _loc_13:int = 0;
            var _loc_14:uint = 0;
            var _loc_15:uint = 0;
            var _loc_16:uint = 0;
            var _loc_17:uint = 0;
            var _loc_2:Boolean = false;
            var _loc_3:Boolean = false;
            var _loc_4:* = param1.useColorMixer2;
            if (param1.useColorType == "双重" && _loc_4)
            {
                _loc_2 = true;
                _loc_8 = _loc_4.split(";");
                _loc_9 = _loc_8.length;
                _loc_10 = new Array();
                _loc_11 = new Array();
                _loc_12 = new Array();
                _loc_13 = 0;
                while (_loc_13 < _loc_9)
                {
                    
                    _loc_14 = uint(_loc_8[_loc_13]);
                    _loc_15 = _loc_14 & 16777215;
                    _loc_14 = _loc_14 >> 24;
                    _loc_16 = _loc_14 & 255;
                    _loc_10.push(_loc_15);
                    _loc_11.push(1);
                    _loc_12.push(_loc_16);
                    _loc_13++;
                }
                this._particleParams.setDoubleColor(_loc_10, _loc_11, _loc_12);
            }
            else
            {
                this._particleParams.setDoubleColor(null, null, null);
            }
            var _loc_5:* = param1.useAlphaMixer2;
            if (param1.useAlphaType == "双重" && _loc_5)
            {
                _loc_3 = true;
                _loc_8 = _loc_5.split(";");
                _loc_9 = _loc_8.length;
                _loc_10 = new Array();
                _loc_11 = new Array();
                _loc_12 = new Array();
                _loc_13 = 0;
                while (_loc_13 < _loc_9)
                {
                    
                    _loc_14 = uint(_loc_8[_loc_13]);
                    _loc_17 = _loc_14 & 255;
                    _loc_14 = _loc_14 >> 8;
                    _loc_16 = _loc_14 & 255;
                    _loc_10.push(16777215 * _loc_17 / 255);
                    _loc_11.push(1);
                    _loc_12.push(_loc_16);
                    _loc_13++;
                }
                this._particleParams.setDoubleAlpha(_loc_10, _loc_11, _loc_12);
            }
            else
            {
                this._particleParams.setDoubleAlpha(null, null, null);
            }
            var _loc_6:* = param1.useColorMixer;
            if (param1.isUseAnimationColor && _loc_6)
            {
                _loc_8 = _loc_6.split(";");
                _loc_9 = _loc_8.length;
                _loc_10 = new Array();
                _loc_11 = new Array();
                _loc_12 = new Array();
                _loc_13 = 0;
                while (_loc_13 < _loc_9)
                {
                    
                    _loc_14 = uint(_loc_8[_loc_13]);
                    _loc_15 = _loc_14 & 16777215;
                    _loc_14 = _loc_14 >> 24;
                    _loc_16 = _loc_14 & 255;
                    _loc_10.push(_loc_15);
                    _loc_11.push(1);
                    _loc_12.push(_loc_16);
                    _loc_13++;
                }
                this._particleParams.setColor(_loc_10, _loc_11, _loc_12, _loc_2);
            }
            else
            {
                this._particleParams.setColor(null, null, null, false);
            }
            var _loc_7:* = param1.useAlphaMixer;
            if (param1.isUseAnimationAlpha && _loc_7)
            {
                _loc_8 = _loc_7.split(";");
                _loc_9 = _loc_8.length;
                _loc_10 = new Array();
                _loc_11 = new Array();
                _loc_12 = new Array();
                _loc_13 = 0;
                while (_loc_13 < _loc_9)
                {
                    
                    _loc_14 = uint(_loc_8[_loc_13]);
                    _loc_17 = _loc_14 & 255;
                    _loc_14 = _loc_14 >> 8;
                    _loc_16 = _loc_14 & 255;
                    _loc_10.push(16777215 * _loc_17 / 255);
                    _loc_11.push(1);
                    _loc_12.push(_loc_16);
                    _loc_13++;
                }
                this._particleParams.setAlpha(_loc_10, _loc_11, _loc_12, _loc_3);
            }
            else
            {
                this._particleParams.setAlpha(null, null, null, false);
            }
            return;
        }// end function

        private function parserHeadInfo(param1:Object) : void
        {
            var _loc_2:* = param1.texture;
            if (!_loc_2 || _loc_2 == EngineConstName.defaultNullStringFlag)
            {
                this._particleParams.materialUrl = 10066329;
            }
            else
            {
                this._particleParams.materialUrl = _loc_2;
            }
            this._particleParams.totalTime = int.MAX_VALUE;
            return;
        }// end function

        private function parserBaseInfo(param1:Object) : void
        {
            this._particleParams.particleLife = param1.life;
            this._particleParams.life_variation = param1.life_variation;
            this._particleParams.size = param1.size;
            this._particleParams.size_variation = param1.size_variation;
            this._particleParams.useTimeGrowth = param1.useTimeGrowth;
            this._particleParams.doubleFace = param1.doubleFace;
            this._particleParams.randomValue = param1.randomValue;
            this._faceTransform = new Matrix3D();
            var _loc_2:* = param1.particleFaceDirection;
            switch(_loc_2)
            {
                case EngineConstName.particleFaceDirection0:
                {
                    this._faceTransform = null;
                    break;
                }
                case EngineConstName.particleFaceDirection1:
                {
                    this._faceTransform.appendRotation(-90, Vector3D.X_AXIS);
                    this._particleParams.faceCamera = true;
                    break;
                }
                case EngineConstName.particleFaceDirection2:
                {
                    this._faceTransform = null;
                    this._particleParams.faceMovingDirection = true;
                    break;
                }
                case EngineConstName.particleFaceDirection3:
                {
                    this._faceTransform = null;
                    break;
                }
                case EngineConstName.particleFaceDirection4:
                {
                    this._faceTransform.appendRotation(180, Vector3D.X_AXIS);
                    break;
                }
                case EngineConstName.particleFaceDirection5:
                {
                    this._faceTransform.appendRotation(90, Vector3D.Z_AXIS);
                    break;
                }
                case EngineConstName.particleFaceDirection6:
                {
                    this._faceTransform.appendRotation(-90, Vector3D.Z_AXIS);
                    break;
                }
                case EngineConstName.particleFaceDirection7:
                {
                    this._faceTransform.appendRotation(-90, Vector3D.X_AXIS);
                    break;
                }
                case EngineConstName.particleFaceDirection8:
                {
                    this._faceTransform.appendRotation(90, Vector3D.X_AXIS);
                    break;
                }
                default:
                {
                    this._faceTransform = null;
                    break;
                }
            }
            this.createParticleInstance(param1);
            return;
        }// end function

        private function createParticleInstance(param1:Object) : void
        {
            var _loc_3:String = null;
            var _loc_4:Number = NaN;
            var _loc_5:String = null;
            var _loc_2:* = param1.particleType;
            this._instancingObject = new OneParticleInstance();
            if (_loc_2 == EngineConstName.particleType0)
            {
                _loc_3 = this._particleParams.faceMovingDirection ? ("z") : ("y");
                _loc_4 = param1.rotateUV == null ? (0) : (param1.rotateUV);
                this._instancingObject.init(OneParticleInstance.CrossPlane, [param1.particleShapeWidth, param1.particleShapeHeight, _loc_3, _loc_4]);
            }
            else if (_loc_2 == EngineConstName.particleType1)
            {
                this._instancingObject.init(OneParticleInstance.Box, [param1.particleShapeWidth, param1.particleShapeHeight, param1.particleShapeLength]);
            }
            else if (_loc_2 == EngineConstName.particleType2)
            {
                if (param1.resourceFiles || this._useThread)
                {
                    if (param1.resourceFiles && param1.resourceFiles.particleMesh)
                    {
                        this._instancingObject.init(OneParticleInstance.Mesh, [param1.resourceFiles.particleMesh]);
                    }
                    else
                    {
                        this.errorInfo = "选择了粒子形状为mesh，但却没有指定相应的mesh文件";
                        return;
                    }
                }
                else
                {
                    _loc_5 = param1.particleMesh;
                    if (!_loc_5 || _loc_5 == EngineConstName.defaultNullStringFlag)
                    {
                        this.errorInfo = "选择了粒子形状为mesh，但却没有指定相应的mesh文件";
                        return;
                    }
                    this._instancingObject.init(OneParticleInstance.Mesh, [_loc_5]);
                }
            }
            else
            {
                if (this._particleParams.faceMovingDirection && param1.formation == EngineConstName.emitterShapeChoose7)
                {
                    _loc_3 = "-yz";
                }
                else
                {
                    _loc_3 = "+xz";
                }
                this._instancingObject.init(OneParticleInstance.Plane, [param1.particleShapeWidth, param1.particleShapeHeight, _loc_3]);
            }
            return;
        }// end function

        private function parserEmitterInfo(param1:Object) : void
        {
            if (this._errorInfo)
            {
                return;
            }
            this._particleParams.emitCountType = param1.emitCountType;
            this._particleParams.birth_rate = param1.birth_rate;
            this._particleParams.total_number = param1.birth_count;
            if (this._particleParams.emitCountType == EngineConstName.emmitUser)
            {
                this._particleParams.emitUserObject = new EmitUserObject(param1.user_Emitter, param1.birth_OnePos);
            }
            else
            {
                this._particleParams.emitUserObject = null;
            }
            var _loc_2:* = param1.emitType;
            switch(_loc_2)
            {
                case EngineConstName.emitTime0:
                {
                    this._particleParams.emitterTime = 1;
                    break;
                }
                case EngineConstName.emitTime1:
                {
                    this._particleParams.emitterTime = param1.emitter_stop;
                    break;
                }
                case EngineConstName.emitTime2:
                {
                    this._particleParams.emitterTime = int.MAX_VALUE;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._directionInfo = new Object();
            this._directionInfo.isRandom = param1.roundType == EngineConstName.linearFlag ? (false) : (true);
            this._directionInfo.motionType = EngineConstName.getMotionType(param1.motionType);
            this._directionInfo.direction_vector_x = param1.direction_vector_x;
            this._directionInfo.direction_vector_y = param1.direction_vector_y;
            this._directionInfo.direction_vector_z = param1.direction_vector_z;
            this._directionInfo.directionVariation = param1.directionVariation;
            this._directionInfo.herizonAngle = param1.herizonAngle * MathConsts.DEGREES_TO_RADIANS;
            this._directionInfo.direction_rotateX = param1.direction_rotate_space ? (param1.direction_rotate_space) : (0);
            this._directionInfo.direction_rotateY = param1.direction_rotate ? (param1.direction_rotate) : (0);
            this._directionInfo.direction_rotateZ = param1.direction_rotateZ ? (param1.direction_rotateZ) : (0);
            this._directionInfo.direction_radian = param1.direction_radian ? (param1.direction_radian) : (360);
            this.parserEmitterType(param1);
            this._particleParams.speed = param1.speed;
            this._particleParams.speed_variation = param1.speed_variation;
            this._particleParams.useEndPoint = this._directionInfo.motionType == 6;
            this._particleParams.destinationX = param1.destination_x;
            this._particleParams.destinationY = param1.destination_y;
            this._particleParams.destinationZ = param1.destination_z;
            return;
        }// end function

        private function parserEmitterType(param1:Object) : void
        {
            var _loc_3:EmitterObject = null;
            var _loc_5:String = null;
            var _loc_6:Number = NaN;
            var _loc_7:Number = NaN;
            var _loc_8:Number = NaN;
            var _loc_9:Number = NaN;
            var _loc_10:Number = NaN;
            var _loc_11:Number = NaN;
            var _loc_12:Number = NaN;
            var _loc_13:Number = NaN;
            var _loc_14:Number = NaN;
            var _loc_15:Number = NaN;
            var _loc_16:uint = 0;
            if (this._errorInfo)
            {
                return;
            }
            this._particleParams.formation = param1.formation;
            var _loc_2:* = param1.emitPlace;
            var _loc_4:* = param1.emitterTransform;
            if (this._particleParams.formation == EngineConstName.emitterShapeChoose8)
            {
                _loc_3 = new UserEmitter(param1.emiter_user, _loc_4, this._particleParams.emitUserObject);
            }
            else if (this._particleParams.formation == EngineConstName.emitterShapeChoose6)
            {
                if (param1.resourceFiles || this._useThread)
                {
                    if (param1.resourceFiles && param1.resourceFiles.emitterShapeChoose)
                    {
                        _loc_3 = new NodeEmitter(param1.resourceFiles.emitterShapeChoose, _loc_2, _loc_4);
                    }
                    else
                    {
                        this.errorInfo = "选择了发射器为mesh，但却没有指定相应的mesh文件";
                        return;
                    }
                }
                else
                {
                    _loc_5 = param1.emitterShapeChoose;
                    if (!_loc_5 || _loc_5 == EngineConstName.defaultNullStringFlag)
                    {
                        this.errorInfo = "选择了发射器为mesh，但却没有指定相应的mesh文件";
                        return;
                    }
                    _loc_3 = new NodeEmitter(_loc_5, _loc_2, _loc_4);
                }
            }
            else
            {
                var _loc_17:* = param1.emitter_width;
                this._particleParams.emitter_width = param1.emitter_width;
                _loc_6 = _loc_17;
                var _loc_17:* = param1.emitter_height;
                this._particleParams.emitter_height = param1.emitter_height;
                _loc_7 = _loc_17;
                var _loc_17:* = param1.emitter_length;
                this._particleParams.emitter_length = param1.emitter_length;
                _loc_8 = _loc_17;
                var _loc_17:* = param1.emitter_rad;
                this._particleParams.emitter_rad = param1.emitter_rad;
                _loc_9 = _loc_17;
                _loc_10 = param1.emitter_rotate_space ? (param1.emitter_rotate_space) : (0);
                _loc_11 = param1.emitter_rotate ? (param1.emitter_rotate) : (0);
                _loc_12 = param1.emitter_rotateZ ? (param1.emitter_rotateZ) : (0);
                _loc_13 = param1.emitter_radian ? (param1.emitter_radian) : (360);
                var _loc_17:* = param1.emitterShapeTopR;
                this._particleParams.emitter_rad = param1.emitterShapeTopR;
                _loc_14 = _loc_17;
                var _loc_17:* = param1.emitterShapeBottomR;
                this._particleParams.emitter_rad = param1.emitterShapeBottomR;
                _loc_15 = _loc_17;
                _loc_16 = this._particleParams.total_number;
                switch(this._particleParams.formation)
                {
                    case EngineConstName.emitterShapeChoose0:
                    {
                        _loc_3 = new SphereEmitter(_loc_9, 1, _loc_2, _loc_4);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose1:
                    {
                        _loc_3 = new RoundEmitter(_loc_9, _loc_13, _loc_10, _loc_11, _loc_12, _loc_2, this._directionInfo.isRandom, _loc_4);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose2:
                    {
                        _loc_3 = new SphereEmitter(_loc_9, 0.5, _loc_2, _loc_4);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose3:
                    {
                        _loc_3 = new CylinderEmitter(_loc_14, _loc_15, _loc_7, _loc_2, _loc_4);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose4:
                    {
                        _loc_3 = new BoxEmitter(_loc_6, _loc_7, _loc_8, _loc_2, _loc_4);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose5:
                    {
                        _loc_3 = new PlaneEmitter(_loc_6, _loc_7, _loc_2, _loc_4, this._directionInfo.isRandom, _loc_16);
                        break;
                    }
                    case EngineConstName.emitterShapeChoose7:
                    {
                        _loc_3 = new SkyEmitter(_loc_2, Capabilities.screenResolutionX, Capabilities.screenResolutionY);
                        this._particleParams.total_number = this._particleParams.total_number * SkyEmitter(_loc_3).getBirthCountRate();
                        break;
                    }
                    default:
                    {
                        break;
                    }
                }
            }
            if (_loc_2 == EmitterPosType.TextureRGB)
            {
                if (param1.resourceFiles || this._useThread)
                {
                    if (param1.resourceFiles && param1.resourceFiles.emitterTextureChoose)
                    {
                        _loc_3.initTexture(param1.resourceFiles.emitterTextureChoose);
                    }
                    else
                    {
                        this.errorInfo = "选择了发射方式为texture，但却没有texture文件";
                        return;
                    }
                }
                else
                {
                    _loc_3.initTexture(param1.emitterTextureChoose);
                }
            }
            this._particleParams.setEmitterObject(_loc_3);
            return;
        }// end function

    }
}
